package com.ziyun.admin.web.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.sys.entity.SysLoginInforEntity;
import io.renren.modules.sys.service.SysLoginInforService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 系统访问记录
 *
 * @author 'zh'
 * @email 
 * @date 2018-11-26 15:50:22
 */
@RestController
@RequestMapping("sys/popsyslogininfor")
public class SysLoginInforController {
    @Autowired
    private SysLoginInforService sysLoginInforService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:popsyslogininfor:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysLoginInforService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{infoId}")
    @RequiresPermissions("sys:popsyslogininfor:info")
    public R info(@PathVariable("infoId") Integer infoId){
        SysLoginInforEntity popSysLoginInfor = sysLoginInforService.selectById(infoId);

        return R.ok().put("popSysLoginInfor", popSysLoginInfor);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:popsyslogininfor:save")
    public R save(@RequestBody SysLoginInforEntity popSysLoginInfor){
        sysLoginInforService.insert(popSysLoginInfor);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:popsyslogininfor:update")
    public R update(@RequestBody SysLoginInforEntity popSysLoginInfor){
        ValidatorUtils.validateEntity(popSysLoginInfor);
        sysLoginInforService.updateAllColumnById(popSysLoginInfor);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:popsyslogininfor:delete")
    public R delete(@RequestBody Integer[] infoIds){
        sysLoginInforService.deleteBatchIds(Arrays.asList(infoIds));

        return R.ok();
    }

}
